<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <!--通用查询-->
      <queryHeader :dict="dict" :permission="permission" />
      <!--通用编辑-->
      <crudOperation :permission="permission" />
    </div>

    <!--表格渲染-->
    <el-table ref="table" v-loading="crud.loading" :data="crud.data" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
      <!--多选框-->
      <el-table-column type="selection" width="55" />
      <!--展示字段-->
      <el-table-column v-if="columns.visible('pushTime')" prop="pushTime" label="推送时间" :show-overflow-tooltip="true" />
      <el-table-column v-if="columns.visible('pushType')" prop="pushType" label="推送方式" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          {{ dict.label.type_push_channel[scope.row.pushType] }}
        </template>
      </el-table-column>
      <el-table-column v-if="columns.visible('pushSender')" prop="pushSender" label="推送方" :show-overflow-tooltip="true" />
      <el-table-column v-if="columns.visible('pushReceiver')" prop="pushReceiver" label="接收方" :show-overflow-tooltip="true" />
      <el-table-column v-if="columns.visible('pushTitle')" prop="pushTitle" label="推送标题" :show-overflow-tooltip="true" />
      <el-table-column v-if="columns.visible('pushContent')" prop="pushContent" label="推送内容" :show-overflow-tooltip="true" />
      <el-table-column v-if="columns.visible('pushStatus')" prop="pushStatus" label="推送状态" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          {{ dict.label.status_push[scope.row.pushStatus] }}
        </template>
      </el-table-column>

      <!--操作-->
      <el-table-column label="操作" width="130px" align="center" fixed="right">
        <template slot-scope="scope">
          <!--通用编辑删除-->
          <udOperation :data="scope.row" :permission="permission" />
        </template>
      </el-table-column>
    </el-table>

    <!--分页组件-->
    <pagination />

    <!--表单渲染-->
    <editForm :dict="dict" />
  </div>
</template>

<script>
import crudPushHistory from '@/api/business/bed/push'
import queryHeader from './module/queryHeader'
import editForm from './module/editForm'
import CRUD, { presenter } from '@crud/crud'
import crudOperation from '@crud/CRUD.operation'
import pagination from '@crud/Pagination'
import udOperation from '@crud/UD.operation'

// crud交由presenter持有
const crud = CRUD({ title: 't_push_history', url: 'push/history/list/page/token', crudMethod: { ...crudPushHistory }, pkIdName: 'id', queryOnPresenterCreated: false })

export default {
  name: 'PushHistory',
  components: { queryHeader, editForm, crudOperation, pagination, udOperation },
  dicts: ['type_push_channel', 'status_push'],
  mixins: [presenter(crud)],
  data() {
    return {
      // 对应几个按钮操作
      permission: {
        add: [],
        edit: [],
        del: []
      }
    }
  },
  created() {
    this.crud.optShow = { add: false, edit: false, del: false, download: true }

    this.crud.params.rentUserId = this.$route.query.rentUserId

    this.crud.toQuery()
  },
  methods: {

  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  /deep/ .el-input-number .el-input__inner {
    text-align: left;
  }
</style>
